#include "SecurityModule.h"
#include "Protocol/Protocol.h"
//#include "Common/NFPluginModule/NFIEventModule.h"

bool FragrantGrass::SecurityModule::Init()
{
	//m_pKernelModule = m_pPluginManager->FindModule<NFIKernelModule>();
	//m_pClassModule = m_pPluginManager->FindModule<NFIClassModule>();
	m_pLogModule = m_pPluginManager->FindModule<ILogModule>();
	//m_pElementModule = m_pPluginManager->FindModule<NFIElementModule>();
	
	return true;
}

bool FragrantGrass::SecurityModule::AfterInit()
{
	//NF_SHARE_PTR<NFIClass> xLogicClass = m_pClassModule->GetElement(NFrame::Security::ThisName());
	//if (xLogicClass)
	//{
	//	const std::vector<std::string>& strIdList = xLogicClass->GetIDList();
	//	for (int i = 0; i < strIdList.size(); ++i)
	//	{
	//		const std::string& strId = strIdList[i];
	//		const std::string& strSecurityData = m_pElementModule->GetPropertyString(strId, NFrame::Security::SecurityData());

	//	}
	//}

	return true;
}

const std::string & FragrantGrass::SecurityModule::GetSecurityKey(const std::string & strAcount)
{
	return strAcount;
}

bool FragrantGrass::SecurityModule::VirifySecurityKey(const std::string & strAcount, const std::string & strSucrityKey)
{
	//you would implement this function by yourself
	if (strAcount == strSucrityKey)
	{
		return true;
	}

	return false;
}

std::string FragrantGrass::SecurityModule::EncodeMsg(const std::string & strAcount, const std::string & strSucrityKey, const int nMessageID, const char * strMessageData, const int nLen)
{
	return std::string(strMessageData, nLen);
}

std::string FragrantGrass::SecurityModule::EncodeMsg(const std::string & strAcount, const std::string & strSucrityKey, const int nMessageID, const std::string & strMessageData)
{
	return strMessageData;
}

std::string FragrantGrass::SecurityModule::DecodeMsg(const std::string & strAcount, const std::string & strSucrityKey, const int nMessageID, const char * strMessageData, const int nLen)
{
	return std::string(strMessageData, nLen);
}

std::string FragrantGrass::SecurityModule::DecodeMsg(const std::string & strAcount, const std::string & strSucrityKey, const int nMessageID, const std::string & strMessageData)
{
	return strMessageData;
}

bool FragrantGrass::SecurityModule::Shut()
{

	return true;
}

bool FragrantGrass::SecurityModule::Execute()
{
	return true;
}
